Skip to content

feat: Add PHPUnit configuration and unit tests for Hyvä compatibility…#212

Merged
dermatz merged 7 commits into
mainfrom
feat/phpunit+compatibilty-checker
Jun 28, 2026
Merged

feat: Add PHPUnit configuration and unit tests for Hyvä compatibility…#212
dermatz merged 7 commits into
mainfrom
feat/phpunit+compatibilty-checker

Conversation

@dermatz

@dermatz dermatz commented Jun 28, 2026

Copy link
Copy Markdown
Member

This pull request introduces PHPUnit test support and refines the Hyvä compatibility checking logic for improved accuracy and maintainability. The main changes include adding test infrastructure, updating detection logic for Knockout.js and HTML templates, and simplifying code by removing unused methods and parameters.

Testing infrastructure:

  • Added PHPUnit support:
    • New .github/workflows/phpunit.yml GitHub Actions workflow to run unit tests on pull requests.
    • Added phpunit/phpunit to composer.json and configured PSR-4 autoloading for tests.
    • Added phpunit.xml.dist for test suite configuration.
    • Added a test results cache file.

Compatibility detection improvements:

  • Enhanced Knockout.js pattern detection to cover more usages (e.g., pureComputed, applyBindings, components, bindingHandlers, and data-bind attribute). [1] [2]
  • Added detection for Knockout.js virtual element bindings in templates.
  • Extended file scanning to include .html files in addition to .js, .xml, and .phtml. [1] [2]

Codebase simplification and robustness:

  • Removed unused methods and parameters from CompatibilityChecker, IncompatibilityDetector, and ModuleScanner (e.g., output interface, severity helpers, redundant extension methods). [1] [2] [3] [4] [5]
  • Updated exception handling to catch all \Throwable instead of just \Exception for better error resilience. [1] [2] [3]

Result reporting improvements:

  • Status display now includes a Hyvä-Aware marker for modules that support Hyvä, and warning/incompatibility messages are more descriptive.
  • Warnings alone now trigger the display of detailed recommendations, improving reporting accuracy.

API changes:

  • Simplified method signatures for getDetailedIssues, removing unnecessary parameters. [1] [2]
  • Updated all relevant call sites to match new method signatures.

These changes collectively improve testability, detection accuracy, and code maintainability.… detection

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds PHPUnit-based unit testing to MageForge and refines the Hyvä compatibility scanning/reporting logic (broader Knockout/template detection, simplified APIs, and more resilient error handling).

Changes:

  • Introduce PHPUnit test infrastructure (dependency, config, CI workflow) and add unit tests for IncompatibilityDetector.
  • Expand Hyvä incompatibility detection to include more Knockout patterns and scan .html templates in addition to .js, .xml, and .phtml.
  • Simplify compatibility-check APIs/output logic (signature cleanup, improved status display, and \Throwable-based resilience).

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/Unit/Service/Hyva/IncompatibilityDetectorTest.php Adds unit tests covering JS/XML/PHTML/HTML pattern detection and edge cases.
src/Service/Hyva/ModuleScanner.php Extends scanning to .html files and reuses detector extension parsing; broadens exception catch to \Throwable.
src/Service/Hyva/IncompatibilityDetector.php Expands Knockout/template pattern detection, maps .html into template scanning, and makes extension parsing reusable.
src/Service/Hyva/CompatibilityChecker.php Adjusts summary/detail triggering for warnings, improves Hyvä-aware status display, and simplifies getDetailedIssues() signature.
src/Console/Command/Hyva/CompatibilityCheckCommand.php Updates call sites to the simplified CompatibilityChecker method signatures.
phpunit.xml.dist Adds PHPUnit suite configuration (bootstrap, cache directory, source include).
composer.json Adds phpunit/phpunit and PSR-4 autoload-dev for tests.
.phpunit.cache/test-results Adds a PHPUnit test result cache artifact.
.github/workflows/phpunit.yml Adds a GitHub Actions workflow to run PHPUnit on pull requests.
Files not reviewed (1)
  • .phpunit.cache/test-results: Generated file
Comments suppressed due to low confidence (1)

src/Service/Hyva/IncompatibilityDetector.php:205

  • getExtensionFromPath() was made public and is now used by ModuleScanner, which increases IncompatibilityDetector's public API surface and couples scanning logic to a detector implementation detail. Prefer keeping extension parsing as a private helper in ModuleScanner (or extracting a small shared path utility) so IncompatibilityDetector only exposes detection-related behaviour.
    /**
     * Get file extension without using pathinfo().
     *
     * @param string $path
     * @return string
     */
    public function getExtensionFromPath(string $path): string
    {
        $normalized = str_replace('\\', '/', $path);
        $trimmed = rtrim($normalized, '/');
        $pos = strrpos($trimmed, '/');
        $basename = $pos === false ? $trimmed : substr($trimmed, $pos + 1);
        $dot = strrpos($basename, '.');

Comment thread .phpunit.cache/test-results Outdated
Copilot AI review requested due to automatic review settings June 28, 2026 06:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 10 changed files in this pull request and generated 1 comment.

Comment thread src/Console/Command/Hyva/CompatibilityCheckCommand.php Outdated
Copilot AI review requested due to automatic review settings June 28, 2026 07:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 10 changed files in this pull request and generated 3 comments.

Comment thread src/Service/Hyva/IncompatibilityDetector.php Outdated
Comment thread src/Service/Hyva/IncompatibilityDetector.php Outdated
Comment thread src/Service/Hyva/IncompatibilityDetector.php Outdated
Copilot AI review requested due to automatic review settings June 28, 2026 16:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 10 changed files in this pull request and generated 1 comment.

Comment on lines 228 to 232
@@ -234,13 +232,7 @@ private function runScan(
$excludeVendor = false;
@dermatz dermatz merged commit b72c7c1 into main Jun 28, 2026
17 checks passed
@dermatz dermatz deleted the feat/phpunit+compatibilty-checker branch June 28, 2026 16:33
@github-actions github-actions Bot mentioned this pull request Jun 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants